﻿// Copyright (c) Inossem. All rights reserved.
// Licensed under the LGPL-3.0 license. See LICENSE file in the project root for full license information.
using System;
using System.Activities;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DWF.Studio.Script
{
    /// <summary>
    /// 脚本执行事件基类
    /// </summary>
    internal class BaseScriptExcuteEventArgs : EventArgs
    {
        public string ExecutionId
        {
            set;
            get;
        }
    }

    /// <summary>
    /// 脚本执行中止
    /// </summary>
    internal class ScriptExcuteAbortedEventArgs : BaseScriptExcuteEventArgs
    {
        /// <summary>
        /// 原因
        /// </summary>
        public string Reason
        {
            set;
            get;
        }
    }

    /// <summary>
    /// 脚本执行完成
    /// </summary>
    internal class ScriptExcuteCompletedEventArgs : BaseScriptExcuteEventArgs
    {
        /// <summary>
        /// 终结信息
        /// </summary>
        public string TerminationMessage
        {
            set;
            get;
        }

        public IDictionary<string, object> Outputs
        {
            set;
            get;
        }
    }

    /// <summary>
    /// 脚本执行中未处理异常
    /// </summary>
    internal class ScriptExcuteUnhandledExceptionEventArgs : BaseScriptExcuteEventArgs
    {
        public string TypeName
        {
            set;
            get;
        }

        public string StackTrace
        {
            set;
            get;
        }

        public string Message
        {
            set;
            get;
        }

        public string Location
        {
            set;
            get;
        }

        public string ScriptPath
        {
            set;
            get;
        }

        public override string ToString()
        {
            return $"{TypeName}{System.Environment.NewLine}{Message}{System.Environment.NewLine}{StackTrace}";
        }
    }

    internal class SubScriptExecuteStartEventArgs : BaseScriptExcuteEventArgs
    {
        public string ScriptPath
        {
            set;
            get;
        }
    }

    internal class SubScriptExecuteEndEventArgs : BaseScriptExcuteEventArgs
    {
        public string ParentExecutionId
        {
            set;
            get;
        }
    }

    internal class ExecuteStartEventArgs : BaseScriptExcuteEventArgs
    {
    }

    internal class ExecuteEndEventArgs : BaseScriptExcuteEventArgs
    {
    }

    internal class HitBreakpointEventArgs : BaseScriptExcuteEventArgs
    {
        public string ScriptPath
        {
            set;
            get;
        }

        public string Verb
        {
            get;
            set;
        }

        public string Location
        {
            get;
            set;
        }
    }
}
